package com.unipay.cmn.lintener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.unipay.cmn.mapper.DictMapper;
import com.unipay.model.cmn.Dict;
import com.unipay.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

/**
 * @Project: yitong_parent
 * @Author: C.yu
 * @Time: 2023-04-02 13:27:58
 * @Desc: TODO
 */

public class DictListener extends AnalysisEventListener<DictEeVo> {

    //构造器，加入service或mapper
    private DictMapper dictMapper;
    public DictListener(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    //一行一行，读取数据
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        //TODO 调用方法，添加数据库
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo, dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
